package com.explorex.infra.puma.gateway.netty.common;

import lombok.Data;

import java.util.Map;
import java.util.Objects;

/**
 * @author: JacceYang
 * @createTime: 2022/10/12 20:50
 * @description:
 */
@Data
public class UserKey {
    private String userId;
    private String domain;
    private int terminal;
    private Map<String, String> extension;
    private String bizSystem;

    public UserKey(String userId, String domain, int terminal) {
        this.userId = userId;
        this.domain = domain;
        this.terminal = terminal;
    }

    public UserKey(String userId, String domain, int terminal, Map<String, String> extension) {
        this.userId = userId;
        this.domain = domain;
        this.terminal = terminal;
        this.extension = extension;
    }

    public String domainUser() {
        return String.format("%s@%s", this.userId, this.domain);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserKey)) return false;
        UserKey userKey = (UserKey) o;
        return userId.equals(userKey.userId) && domain.equals(userKey.domain);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, domain);
    }
}
